<%@ page import="top.huhuiyu.javabasic.javabasictemplate.entity.TbNews" %>
<%@ page import="java.util.List" %>
<%@ page import="top.huhuiyu.javabasic.javabasictemplate.entity.Page" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>新闻管理</title>
</head>
<body>
<h1>新闻管理</h1>
<form action="<%=request.getContextPath()%>/news/add.action" method="post">
    <input name="title" placeholder="标题">
    <input name="info" placeholder="内容">
    <input name="source" placeholder="来源">
    <button type="submit">添加</button>
</form>

<%
    List<TbNews> list = (List<TbNews>) request.getAttribute("list");
    Page pageinfo = (Page) request.getAttribute("page");
    TbNews tbNews = (TbNews) request.getAttribute("query");
%>
<table style="width: 100%;">
    <thead>
    <tr>
        <td>编号</td>
        <td>标题</td>
        <td>来源</td>
        <td>信息最后修改时间</td>
    </tr>
    </thead>
    <tbody>
    <%
        for (TbNews news : list) {
    %>
    <tr>
        <td><%=news.getNid()%>
        </td>
        <td><%=news.getTitle()%>
        </td>
        <td><%=news.getSource()%>
        </td>
        <td><%=news.getLastupdate()%>
        </td>
    </tr>
    <%
        }
    %>
    </tbody>
</table>

<hr>

<form action="<%=request.getContextPath()%>/news/list.action" method="get">
    <input type="text" name="title" value="<%=tbNews.getTitle()%>" placeholder="标题模糊查询">
    <input type="text" name="source" value="<%=tbNews.getSource()%>" placeholder="新闻来源模糊查询">
    页码：
    <select name="pageNumber">
        <%
            for (int i = 1; i <= pageinfo.getPageCount(); i++) {
        %>
        <option value="<%=i%>" <%= i==pageinfo.getPageNumber()?"selected":"" %>><%=i%></option>
        <%
            }
        %>
    </select>
    <button type="submit">查询</button>
</form>

记录总数/当前页/分页数：<%=pageinfo.getTotal()%>/<%=pageinfo.getPageNumber()%>/<%=pageinfo.getPageCount()%>
</body>
</html>